﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            /*1、生成一个随机整型数组，长度是10，内容是1~10，数组内容不重复。*/
            Random ran = new Random();
            int[] arr = new int[10];

            for (int i = 0; i < arr.Length;)
            {
                int num = ran.Next(1,11);
                if (!arr.Contains(num)) {
                    arr[i] = num;
                    i++;
                }
            }

            /*foreach (int item in arr)
            {
                Console.Write(item +"\t");
            }
            Console.WriteLine();*/
            Console.WriteLine(string.Join(",",arr));


            //2、生成0 - 5之间的随机小数，保留两位小数。
            double num2 = ran.NextDouble() * 5;
           /* for (int i = 0; i < 100; i++)
            {
                num2 = ran.NextDouble() * 5;
                Console.WriteLine(num2.ToString("f2"));
            }
*/
            Console.WriteLine(num2.ToString("f2"));


            //3、生成4 - 7之间的随机小数，保留两位小数。
            double num3 = (ran.NextDouble() * 3)+ 4;
            /*for (int i = 0; i < 100; i++)
            {
                num3 = (ran.NextDouble() * 3) + 4;
                Console.WriteLine(num3.ToString("f2"));
            }*/

            Console.WriteLine(num3.ToString("f2"));

            // 4、用户输入邮箱，请验证其合法性。
            // 1651651fsdsd.d@
            /*Regex regex = new Regex(@"^\w+(\.\w+)?@\w+(\.\w+)+$");
            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine("请输入邮箱:");
                string input = Console.ReadLine();
                if (regex.IsMatch(input))
                {
                    Console.WriteLine("正确");
                }
                else
                {
                    Console.WriteLine("错误");
                }
            }*/

            //5、用户输入手机号码，请验证其合法性。
            Regex ren = new Regex(@"^1[3-9]\d{9}$");
            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine("请输入手机号码：");
                string input1 = Console.ReadLine();
                if (ren.IsMatch(input1))
                {
                    Console.WriteLine("正确");
                }
                else
                {
                    Console.WriteLine("错误");
                }

            }
            

        }



    }
}
